// Copyright (C) 2016 All rights reserved.
// Author: liufeng11@letv.com (Liu Feng)
// Description:

#include "MyFontFeatureExtractor.h"
#include "HaarFontFeatureExtractor.h"
#include "HogFontFeatureExtractor.h"
#include "MySimilarity.h"
#include "SimilarCharacter.h"
#include <stdio.h>

void WriteFeature(FILE* fp, unsigned int charCode, const std::vector<double> &f) {
  fprintf(fp, "%04x ", charCode);
  if (f.empty()) {
    fprintf(fp, "\n");
    return;
  }
  
  fprintf(fp, "%.15lf", f[0]);
  
  for (size_t i = 1; i < f.size(); ++i) {
    fprintf(fp, ",%.15lf", f[i]);
  }
  
  fprintf(fp, "\n");
  return;
}

void Write2Local(FILE* fp, unsigned int begin, unsigned int end) {
  unsigned int iter = begin;
  unsigned int last = end;
  HogFontFeatureExtractor ffe;
  while(iter != last) {
    std::vector<double> f;
    if (ffe.GetFeature(iter, &f)) {
      WriteFeature(fp, iter, f);
    }
    else {
    }
    ++iter;
  }
}
void ExtractFeature() {
  FILE *fp = fopen("../conf/features.dat", "w");
  
  // Write2Local(fp, 0x3400, 0x4db6);
  Write2Local(fp, 0x4e00, 0x9fcc);

  fclose(fp);
}

int main() {

  ExtractFeature();
  return 0;
}
